package songZhao.MinaDemo.Example;

public class ProtocolPack {
	private int length;
	private byte flag;
	private String content;
	
	
	@Override
	public String toString() {
		return "ProtocolPack [length=" + length + ", flag=" + flag + ", content=" + content + "]";
	}

	public ProtocolPack(byte flag, String content) {
		this.flag = flag;
		this.content = content;
		/**
		 * 这里是用来计算报文长度的. 如果内容是null,那么长度就等于一个int和一个byte的长度,
		 * 也就是4+1,如果不是空的,再加上报文内容的长度即可.
		 */
		if (content == null) {
			length = 5;
		}else {
			length = 5+ content.getBytes().length;
		}
	}
	
	public int getLength() {
		return length;
	}
	public void setLength(int length) {
		this.length = length;
	}
	public byte getFlag() {
		return flag;
	}
	public void setFlag(byte flag) {
		this.flag = flag;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	
}
